<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');   

    class Navigator extends CI_Controller  {

        var $data = array();

        function __construct()
        {
            parent::__construct();
        }

        function index() { show_404(); }        

        function core_site($page=NULL,$data=NULL, $sub=NULL,$upsub=NULL){

            if ($data!=NULL){
                $this->data = array_merge((array)$this->data, (array)$data);   
            }

            $this->data['page'] = $page;
            $this->data['sub'] = $sub;
            $this->data['upsub'] = $upsub;
            $this->data['path'] = base_url().'assets/';    
            $this->data['url'] = base_url();    

            $url;

            if(($sub=='')&&($upsub=='')){ 
                
                $url = $page;
                $this->asset->flag('page');

            }else if($upsub==''){ 

                    $url = $page.'/'.$sub;
                    $this->asset->flag('sub');

                }else{

                    $url = $page.'/'.$sub.'/'.$upsub;
                    $this->asset->flag('upsub');

            }

            $this->asset->layoutflag('site');

            $this->asset->initialze_assets($page, $sub, $upsub);

            if(!isset($this->data['title'])){
                $this->data['title'] = 'No title';
                $str = explode('/',$page);
                $this->data['title'] = $str[1];
                
            }

            $this->layout->view($url, $this->data);


        }
        
        function core_cms($page=NULL,$data=NULL, $sub='', $upsub=''){

            if ($data!=NULL){
                $this->data = array_merge((array)$this->data, (array)$data);   
            }

            $this->data['page'] = $page;
            $this->data['sub'] = $sub;
            $this->data['upsub'] = $upsub;
            $this->data['path'] = base_url().'assets/';    
            $this->data['url'] = base_url();    

            $url;

            if(($sub=='')&&($upsub=='')){ 

                $url = 'cms/'.$page;
                $this->asset->flag('page');

            }else if($upsub==''){ 

                    $url = 'cms/'.$page.'/'.$sub;
                    $this->asset->flag('sub');

                }else{

                    $url = 'cms/'.$page.'/'.$sub.'/'.$upsub;
                    $this->asset->flag('upsub');

            }

            $this->asset->layoutflag('cms');
            
            $this->asset->initialze_assets($page, $sub, $upsub);

            //$this->load->model('sitem');
            //$this->data['row'] = $this->sitem->read($page, $sub, $upsub);
            //$this->data['title'] = $this->sitem->getTitle($page, $sub, $upsub);
            
            if(!isset($this->data['title'])){
                $this->data['title'] = 'No title';
                $str = explode('/',$page);
                if(isset($str[1])){
                    $this->data['title'] = $str[1]; 
                }else{
                    $this->data['title'] = 'Dobrodošli';
                }
                
            }

            $this->layout->view($url, $this->data);
        }
     

    }
?>